package com.gao.di;

import com.gao.di.construct.four.component.StaticFactoryDaoImpl2;
import com.gao.di.construct.one.CatDaoImpl;
import com.gao.di.construct.three.component.StaticFactoryDaoImpl;
import com.gao.di.setter.two.Id;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author GaoXi
 * @date 2022/2/21 9:20
 */
public class Starter {


    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("two-di.xml");
        //1.构造函数注入
        CatDaoImpl bean = applicationContext.getBean(CatDaoImpl.class);
        System.out.println(bean);

        //2.setter方法注入
        Id id = applicationContext.getBean(Id.class);
        System.out.println(id);

        //3.静态工厂方法
        StaticFactoryDaoImpl bean1 = applicationContext.getBean(StaticFactoryDaoImpl.class);
        System.out.println(bean1);

        //4.实例工厂方法
        StaticFactoryDaoImpl2 bean2 = applicationContext.getBean(StaticFactoryDaoImpl2.class);
        System.out.println(bean2);
    }

}
